package org.ecjmn.pringles;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * This file is part of MiniBasic.                                 *
 * See the file "MiniBasic-LICENSE" for Copyright information and  *
 * the terms and conditions for copying, distribution and          *
 * modification of MiniBasic.                                      *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.PushbackReader;

import org.ecjmn.pringles.lexer.Lexer;
import org.ecjmn.pringles.node.Node;
import org.ecjmn.pringles.parser.Parser;

public class Main
{
    public static void main(String[] arguments)
    {

        //System.out.println(Version.banner());

        if(arguments.length != 1)
        {
            System.out.println("usage:");
            System.out.println("  java minibasic.Main filename");
            System.exit(1);
        }

        try
        {
            Lexer lexer = new Lexer(
                new PushbackReader(
                new BufferedReader(
                new FileReader(arguments[0])), 1024));

            Parser parser = new Parser(lexer);

            Node ast = parser.parse();

            ast.apply(new Interpreter());  //our starting point for interpreter
        }
        catch(Exception e)
        {
            System.out.println(e);
        }
    }
}
